﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using HotelRegistrationSystem.Models.AttributeValidators;

namespace HotelRegistrationSystem.Models
{
    public class BookingModel
    {
        [Display(Name="Hotel name: ")]
        public string HotelName { get; set; }

        public int HotelId { get; set; }

        public List<RoomModel> Rooms { get; set; }

        [DataType(DataType.DateTime)]
        [MinDate]
        [Required]
        public DateTime StartDate { get; set; }

        [DataType(DataType.DateTime)]
        [MinDate]
        [Required]
        public DateTime EndDate { get; set; }

        [Required(ErrorMessage="Please select a room")]
        public int SelectedRoomId { get; set; }

        public BookingModel()
        {

        }

        public BookingModel(string name, int id, IList<RoomModel> rooms)
        {
            HotelName = name;
            HotelId = id;
            Rooms = rooms.ToList();
            StartDate = DateTime.Now.AddDays(1);
            EndDate = DateTime.Now.AddDays(1);
        }
    }

    public class RoomModel
    {
        public int Id { get; set; }

        public string SummaryName { get; set; }

        public decimal Price { get; set; }

        public RoomModel(int id, decimal price, int bedCnt)
        {
            Id = id;
            Price = price;
            SummaryName = string.Format("{0} beds, ${1}", bedCnt, price);
        }
    }
}